package com.shell.arouter.demo.arouter;

import android.content.Context;

import com.alibaba.android.arouter.facade.annotation.Route;
import com.durian.BaseApp;
import com.durian.base.utils.SPUtils;

/**
 * 说明：UserServiceImpl
 * <p/>
 * 作者：fanly
 * <p/>
 * 类型：Class
 * <p/>
 * 时间：2019-06-21 18:09
 * <p/>
 * 版本：version 1.0
 */
@Route(path = XRouter.User.service_user)
public class UserServiceImpl implements IUserService {

    @Override
    public boolean isLogin() {
        UserBean user = getUser();
        return user != null;
    }

    @Override
    public UserBean getUser() {
        UserBean user = SPUtils.get("user_info").readObject("user",UserBean.class);
        return user;
    }

    @Override
    public void loginSuccess(UserBean bean) {
        SPUtils.get("user_info").writeObject("user",bean);
    }

    @Override
    public void loginExit() {
        SPUtils.deleteFile(BaseApp.getApp(),"user_info");
    }


    @Override
    public void init(Context context) {

    }

    @Override
    public void prepare() {

    }
}
